package com.ruoyi.project.knowledge.metallographic.controller;

import java.util.List;

import com.ruoyi.project.knowledge.InvalidBooks.domain.KnowledgeFailedBooksInfo;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.knowledge.metallographic.domain.KnowledgeSytMetallographicSpectrumInfo;
import com.ruoyi.project.knowledge.metallographic.service.IKnowledgeSytMetallographicSpectrumInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 金相图谱信息Controller
 * 
 * @author ruoyi
 * @date 2024-04-27
 */
@Controller
@RequestMapping("/knowledge/metallographic")
public class KnowledgeSytMetallographicSpectrumInfoController extends BaseController
{
    private String prefix = "knowledge/metallographic";

    @Autowired
    private IKnowledgeSytMetallographicSpectrumInfoService knowledgeSytMetallographicSpectrumInfoService;

    @RequiresPermissions("knowledge:metallographic:view")
    @GetMapping()
    public String metallographic()
    {
        return prefix + "/metallographic";
    }

    /**
     * 查询金相图谱信息列表
     */
    @RequiresPermissions("knowledge:metallographic:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(KnowledgeSytMetallographicSpectrumInfo knowledgeSytMetallographicSpectrumInfo)
    {
        startPage();
        List<KnowledgeSytMetallographicSpectrumInfo> list = knowledgeSytMetallographicSpectrumInfoService.selectKnowledgeSytMetallographicSpectrumInfoList(knowledgeSytMetallographicSpectrumInfo);
        return getDataTable(list);
    }

    /**
     * 导出金相图谱信息列表
     */
    @RequiresPermissions("knowledge:metallographic:export")
    @Log(title = "金相图谱信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(KnowledgeSytMetallographicSpectrumInfo knowledgeSytMetallographicSpectrumInfo)
    {
        List<KnowledgeSytMetallographicSpectrumInfo> list = knowledgeSytMetallographicSpectrumInfoService.selectKnowledgeSytMetallographicSpectrumInfoList(knowledgeSytMetallographicSpectrumInfo);
        ExcelUtil<KnowledgeSytMetallographicSpectrumInfo> util = new ExcelUtil<KnowledgeSytMetallographicSpectrumInfo>(KnowledgeSytMetallographicSpectrumInfo.class);
        return util.exportExcel(list, "金相图谱信息数据");
    }

    /**
     * 新增金相图谱信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存金相图谱信息
     */
    @RequiresPermissions("knowledge:metallographic:add")
    @Log(title = "金相图谱信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(KnowledgeSytMetallographicSpectrumInfo knowledgeSytMetallographicSpectrumInfo)
    {
        return toAjax(knowledgeSytMetallographicSpectrumInfoService.insertKnowledgeSytMetallographicSpectrumInfo(knowledgeSytMetallographicSpectrumInfo));
    }

    /**
     * 金相图谱信息
     */
    @RequiresPermissions("knowledge:metallographic:detail")
    @GetMapping("/detail/{id}")
    public String detail(@PathVariable("id") Long id, ModelMap mmap)
    {
        KnowledgeSytMetallographicSpectrumInfo knowledgeSytMetallographicSpectrumInfo = knowledgeSytMetallographicSpectrumInfoService.selectKnowledgeSytMetallographicSpectrumInfoById(id);
        mmap.put("knowledgeSytMetallographicSpectrumInfo", knowledgeSytMetallographicSpectrumInfo);
        return prefix + "/detail";
    }

    /**
     * 修改金相图谱信息
     */
    @RequiresPermissions("knowledge:metallographic:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        KnowledgeSytMetallographicSpectrumInfo knowledgeSytMetallographicSpectrumInfo = knowledgeSytMetallographicSpectrumInfoService.selectKnowledgeSytMetallographicSpectrumInfoById(id);
        mmap.put("knowledgeSytMetallographicSpectrumInfo", knowledgeSytMetallographicSpectrumInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存金相图谱信息
     */
    @RequiresPermissions("knowledge:metallographic:edit")
    @Log(title = "金相图谱信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(KnowledgeSytMetallographicSpectrumInfo knowledgeSytMetallographicSpectrumInfo)
    {
        return toAjax(knowledgeSytMetallographicSpectrumInfoService.updateKnowledgeSytMetallographicSpectrumInfo(knowledgeSytMetallographicSpectrumInfo));
    }

    /**
     * 删除金相图谱信息
     */
    @RequiresPermissions("knowledge:metallographic:remove")
    @Log(title = "金相图谱信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(knowledgeSytMetallographicSpectrumInfoService.deleteKnowledgeSytMetallographicSpectrumInfoByIds(ids));
    }
}
